package main

import (
	"iris_product/common"
	"iris_product/rabbitmq"
	"iris_product/repositories"
	"iris_product/services"
	"log"
)

func main() {

	// 连接mysql
	db,err := common.NewMysqlConn()
	if err != nil {
		log.Printf("mysql连接错误:" +err.Error())
		return
	}

	// 初始化 productService, orderService
	orderRepository := repositories.NewOrderManager("order",db)
	orderService := services.NewOrderService(orderRepository)

	repoProduct := repositories.NewProductManager("product",db)
	productService := services.NewProductService(repoProduct)
	// 初始化mq
	rabbitmqObj := rabbitmq.NewSimpleRabbitmq("miaosha_order")
	rabbitmqObj.CustomerMessage(orderService,productService)
}